﻿using M.Warehouse.API.Application.Command.ReservoirsCommand;
using M.Warehouse.Domain;
using M.Warehouse.Repository.WarehouseInterface;
using MediatR;

namespace M.Warehouse.API.Application.CommandHandlers.ReservoirsHandlers
{
    public class ReservoirsShowByWarehouseIdCommandHandlers : IRequestHandler<ReservoirsShowByWarehouseIdCommand, List<Reservoirs>>
    {
        private readonly IReservoirsWRepository _reservoirsWRepository;
        public ReservoirsShowByWarehouseIdCommandHandlers(IReservoirsWRepository reservoirsWRepository)
        {
            _reservoirsWRepository = reservoirsWRepository;
        }
        /// <summary>
        /// 显示库区根据仓库id
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<List<Reservoirs>> Handle(ReservoirsShowByWarehouseIdCommand request, CancellationToken cancellationToken)
        {
            var list=(await _reservoirsWRepository.GetAllAsync()).Where(x=>x.WarehouseId==request.WarehouseId).ToList();
            return list;
        }
    }
}
